package com.xiaoshuidi.cloud.module.rooms.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.iot.vo.DeviceReaVo;
import com.xiaoshuidi.cloud.module.rooms.pojo.RoomSdiotWaring;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiaoshuidi.cloud.module.rooms.vo.RoomSdiotWaringVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 预警设置表 Mapper 接口
 * </p>
 *
 * @author James
 * @since 2023-05-29
 */
public interface RoomSdiotWaringMapper extends BaseMapper<RoomSdiotWaring> {
    @Select("SELECT"+" sdm.device_no as deviceNo,"+
            " sdm.device_type as deviceType,"+
            " rda.room_id as roomId,"+
            " rda.waring_id as waringId,"+
            " rsw.cold_worter_waring as coldWorterWaring,"+
            " rsw.ammter_waring as ammterWaring,"+
            " rsw.hot_worter_waring as hotWorterWaring,"+
            " rsw.ammeter_promotion_waring as ammeterPromotionWaring,"+
            " rsw.doorlock_promotion_waring as doorlockPromotionWaring,"+
            " rsw.cold_worter_waring_day as coldWorterWaringDay,"+
            " rsw.ammter_waring_day as ammterWaringDay,"+
            " rsw.hot_worter_waring_day as hotWorterWaringDay,"+
            " rsw.ammeter_promotion_waring_day as ammeterPromotionWaringDay,"+
            " rsw.doorlock_promotion_waring_day as doorlockPromotionWaringDay, "+
            " rsw.cold_worter_waring_read as coldWorterWaringRead,"+
            " rsw.ammter_waring_read as ammterWaringRead,"+
            " rsw.hot_worter_waring_read as hotWorterWaringRead "+
            "FROM " +
            "  room_sdiot_association rda " +
            "LEFT JOIN room_sdiot_waring rsw on rsw.id=rda.waring_id " +
            "LEFT JOIN room_sdiot_device_mapping sdm ON sdm.room_house_id=rda.room_id "+
            "where rda.deleted=0 and sdm.deleted=0 and sdm.device_no is not null and rsw.deleted=0 ")
    List<RoomSdiotWaringVo> getWaringConfig(@Param("ew") QueryWrapper<?> wrapper);

}
